<template>
	<jk-dialog
		v-model="showDialog"
		:title="`进程-${dataItem.processName}`"
		width="900px"
		append-to-body
		:show-close-btn="true"
		:show-confirm-btn="false"
		:show-cancel-btn="false"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form ref="dataItem" :model="dataItem" label-width="110px" :show-message="false">
			<el-row ref="box1">
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="工序">
						<span class="read-only-2">{{ dataItem.processName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="12">
					<el-form-item class="margin-bottom-10" label="排产数量">
						<span class="read-only-2">{{ dataItem.productionQty }}</span>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<jk-table border :stripe="false" :data="dataItem.productOrderMachineList" :height="dialogTableHeight - 14">
			<vxe-column title="机台" align="left" field="machineName" :width="80" />
			<vxe-column title="台日单产" align="right" field="dailyYield" :min-width="100"></vxe-column>
			<vxe-column title="速度" align="right" field="dailyYield" :min-width="100"></vxe-column>
			<vxe-column title="计划开台日期" align="left" field="subPlanStartDate" :min-width="100" />
			<vxe-column title="计划了机日期" align="left" field="subPlanEndDate" :min-width="100" />
			<vxe-column title="排产数量" align="right" field="productionQty" :min-width="100"></vxe-column>
			<vxe-column title="完工数量" align="right" field="completionQty" :min-width="100"></vxe-column>
			<vxe-column title="完工数量" align="center" field="completionQty" :width="100">
				<template slot-scope="scope">
					<div class="flex-center">
						<el-progress type="circle" :percentage="scope.row.productionQty ? parseInt(((scope.row.completionQty || 0) / scope.row.productionQty) * 100) : 0" :width="42"></el-progress>
					</div>
				</template>
			</vxe-column>
		</jk-table>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-dialog-height';
    export default {
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataItem: {
                type: Object,
                default() {
                    return {};
                }
            }
        },
        mixins: [calHeight],
        data() {
            return {
                showDialog: false,
                ruleForm: {}
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                    this.$nextTick(() => {
                        this.$refs.ruleForm.resetFields();
                    });
                }
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
            }
        }
    };
</script>
